//
// Created by hay boy on 2022/6/23.
//

#ifndef ALGORITHMS_UNIT_H
#define ALGORITHMS_UNIT_H
int *equivClass,n;
void initialize(int numberOfElements){
    n = numberOfElements;
    equivClass = new int[n+1];
    for(int e = 1;e<=n;e++){
        equivClass[e] = e;
    }
}
void unite(int classA,int classB){
    for(int k = 1;k<=n;k++){
        if(equivClass[k]==classB){
            equivClass[k] = classA;
        }
    }
}
int find(int theElement){
    return equivClass[theElement];
}
#endif //ALGORITHMS_UNIT_H
